1. Field of the Invention
The present invention relates to audio/video encoding and decoding technology, and more particularly, to a technology for detecting and processing a startcode emulation prevention pattern and startcode.
2. Description of the Prior Art
Audio/video encoding technology has gradually become one of the most important roles of the digital family. Following MPEG2, MP3, VCD, and DVD, an audio/video encoding with MPEG4-AVC format (also known as H.264) or Microsoft VC-1 format has become the basic requirements of current multimedia products, wherein these two formats are widely adopted in HD-DVD and Blue-ray Disc (BD) systems. Due to these two formats having capabilities of high compression, low bit rate, high communication integration, and do not require complex programs, they have become essential requirements within audio/video digital products.
Taking MPEG4-AVC for example, startcode patterns and startcode emulation prevention patterns are already defined in the MPEG4-AVC specification. A pattern ‘00—00—01’ expressed hexadecimally is defined as the startcode, wherein the startcode pattern is inserted into the front end of each NAL unit to discriminate the locations between the beginning of a new NAL unit and the end of its previous NAL unit. During the encoding process, if a pattern identical to the startcode pattern appears in the bit-stream of the encoding result, an emulation prevention byte is inserted into the bit-stream to avoid startcode emulations. For example, when the pattern ‘00—00—01’ appears in the bit-stream of the encoding result, the emulation prevention byte ‘03’ (i.e., 0x03) expressed hexadecimally is inserted into the bit-stream to obtain a new bit-stream segment ‘00—00—03—01’. In addition, the four patterns ‘00—00—03—00’, ‘00—00—03—01’, ‘00—00—03—02’, and ‘00—00—03—03’, are defined as the startcode emulation prevention patterns in the MPEG4-AVC specification.
Because startcode emulation issues always appear in these two formats, a startcode emulation prevention mechanism is designed during the encoding process to distinguish the startcode emulation from the startcode. If the startcode emulation prevention pattern is not detected during the decoding process, the bit-stream can be directly decoded. If the startcode emulation prevention pattern is detected during the decoding process, the emulation prevention byte ‘0x03’ needs to first be moved. If such an operation and the decoding operation are performed at the same time, the complexity of decoding the bit-stream is substantially increased. Thus, the efficiency of processing the bit-stream will be seriously affected especially when dealing with a bit-stream having a high bit rate.